package com.sky.controller.admin;

import com.sky.dto.*;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.AdminOrderService;
import com.sky.vo.OrderPaymentVO;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderSubmitVO;
import com.sky.vo.OrderVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/admin/order")
@Slf4j
@Api(value = "订单相关接口")
public class OrderController {
    @Autowired
    AdminOrderService adminOrderService;


    @GetMapping("/details/{id}")
    public Result<OrderVO> orderDetail(@PathVariable Long id){
        OrderVO orderVO=adminOrderService.orderDetail(id);
        return Result.success(orderVO);
    }
    @GetMapping("/conditionSearch")
    public Result<PageResult> historyOrder(OrdersPageQueryDTO ordersPageQueryDTO){
        PageResult page=adminOrderService.conditionSearch(ordersPageQueryDTO);
        return Result.success(page);

    }
    @PutMapping("/cancel")
    public Result cancel(@RequestBody OrdersCancelDTO ordersCancelDTO){
        adminOrderService.cancel(ordersCancelDTO);

        return Result.success();
    }
    @GetMapping("/statistics")
    public Result<OrderStatisticsVO> statistics(){
        OrderStatisticsVO orderStatisticsVO=adminOrderService.statistics();
        return Result.success(orderStatisticsVO);

    }
    @PutMapping("/confirm")
    public Result confirm(@RequestBody Map<String,Long> id){
        adminOrderService.confirm(id.get("id"));
        return Result.success();

    }
    @PutMapping("/rejection")
    public Result rejection(@RequestBody OrdersRejectionDTO ordersRejectionDTO){
        adminOrderService.rejection(ordersRejectionDTO);
        return Result.success();

    }
    @PutMapping("/delivery/{id}")
    public Result delivery(@PathVariable Long id){
        adminOrderService.delivery(id);
        return Result.success();

    }
    @PutMapping("/complete/{id}")
    public Result complete(@PathVariable Long id){
        adminOrderService.complete(id);
        return Result.success();

    }
}
